$(document).delegate('#order-confirm-btn','click',function(){
		var submit = {
	 			url : '/pub-shopping-member/confirm/',
	 			type : "POST",
	 			dataType : "json",
 	 			success : function(data) {
	 				if (data && data.state && (data.state.indexOf("ERROR") != -1)) {
	 	 				alert(data.message);
	 					return;
	 				} else {
	 					if (data.entity){
	  						alert("Thank you for your application. In a moment, you will be directed to the payment page. \n\nImportant Reminder: \nIf you are registering for the 2 or 3 day CERT course, you are required to submit your Medical Report to COSEM 2 weeks before the course commencement.");
	 						
	 						location.href = data.entity.link;
	   
	 					}else{
//	 						select.removeAttr("disabled");	
//	 						input.removeAttr("disabled");	
	 						alert("Thanks for your application.\n\nImportant Reminder: \nIf you are registering for the 2 or 3 day CERT course, you are required to submit your Medical Report to COSEM 2 weeks before the course commencement.");
	 						//$("#submit_form").hide();
	 						 $( "html,body").animate({ "scrollTop" : 0 }, 600);
	 					}
	 					
	 					
	 				}
	 			}
	};
	$.ajax(submit);
 });

$(document).delegate('#checkout .checkout-content input[name=\'account\']','change', function() {
 	if ($(this).attr('value') == 'register') {
		$('#payment-address .checkout-heading span').html('Step 2: Account &amp; Billing Details');
	} else {
		$('#payment-address .checkout-heading span').html('Step 2: Billing Details');
	}
});

$(document).delegate('.checkout-heading a','click', function() {
	$('.checkout-content').slideUp('slow');
 	$(this).parents(".checkout-heading").next().slideDown('slow');
});
 

$(document).delegate('#button-account','click', function() {
	$.ajax({
		url: '/partial/step2/?account=' + $('input[name=\'account\']:checked').attr('value'),
		dataType: 'html',
		beforeSend: function() {
			$('#button-account').attr('disabled', true);
			$('#button-account').after('<span class="wait">&nbsp;<img src="/resources/images/loading.gif" alt="" /></span>');
		},		
		complete: function() {
			$('#button-account').attr('disabled', false);
			$('.wait').remove();
		},			
		success: function(html) {
			$('.warning, .error').remove();
			
			$('#payment-address .checkout-content').css({opacity:0}).html(html).animate({opacity:1}, 1000);
				
			$('#checkout .checkout-content').slideUp('slow');
				
			$('#payment-address .checkout-content').slideDown('slow');
				
			$('.checkout-heading a').css("visibility", "hidden");
				
			$('#checkout .checkout-heading a').css("visibility", "visible");
			
 			$("#billingCountry").trigger("change");
 		},
		error: function(xhr, ajaxOptions, thrownError) {
			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
		}
	});
});

function loadingShipping(){
	var shipping_address = $('#payment-address input[name=\'deliverySame\']:checked').attr('value');
	
	if (shipping_address) {
		$.ajax({
			url: '/partial/step4/',
			dataType: 'html',
			success: function(html) {
				$('#shipping-method .checkout-content').css({opacity:0}).html(html).animate({opacity:1}, 1000);
				
				$('#payment-address .checkout-content').slideUp('slow');
				
				$('#shipping-method .checkout-content').slideDown('slow');
				
				$('#payment-address .checkout-heading a').css("visibility", "hidden")
				$('#shipping-address .checkout-heading a').css("visibility", "hidden")
				$('#shipping-method .checkout-heading a').css("visibility", "hidden")
				$('#payment-method .checkout-heading a').css("visibility", "hidden")		
												
				$('#payment-address .checkout-heading a').css("visibility", "visible");	
				$('#shipping-address .checkout-heading a').css("visibility", "visible");									
				
				$.ajax({
					url: '/partial/step3/',
					dataType: 'html',
					success: function(html) {
						$('#shipping-address .checkout-content').css({opacity:0}).html(html).animate({opacity:1}, 1000);
						$("#shippingCountry").trigger("change");
					},
					error: function(xhr, ajaxOptions, thrownError) {
						alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
					}
				});
			},
			error: function(xhr, ajaxOptions, thrownError) {
				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
			}
		});					
	} else {
		$.ajax({
			url: '/partial/step3/',
			dataType: 'html',
			success: function(html) {
				$('#shipping-address .checkout-content').css({opacity:0}).html(html).animate({opacity:1}, 1000);
				
				$('#payment-address .checkout-content').slideUp('slow');
				
				$('#shipping-address .checkout-content').slideDown('slow');
				
				$('#payment-address .checkout-heading a').css("visibility", "hidden")
				$('#shipping-address .checkout-heading a').css("visibility", "hidden")
				$('#shipping-method .checkout-heading a').css("visibility", "hidden")
				$('#payment-method .checkout-heading a').css("visibility", "hidden")
				
				$('#payment-address .checkout-heading a').css("visibility", "visible");	
				$("#shippingCountry").trigger("change");
			},
			error: function(xhr, ajaxOptions, thrownError) {
				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
			}
		});
	}
	
	
}

function memberFormError(map){
 
if (map['surName']) {
	$('#payment-address input[name=\'surName\'] + br').after('<span class="error">' + map['surName'] + '</span>');
}

if (map['givenName']) {
	$('#payment-address input[name=\'givenName\'] + br').after('<span class="error">' + map['givenName'] + '</span>');
}	

if (map['email']) {
	$('#payment-address input[name=\'email\'] + br').after('<span class="error">' + map['email'] + '</span>');
}

if (map['telephone']) {
	$('#payment-address input[name=\'telephone\'] + br').after('<span class="error">' + map['telephone'] + '</span>');
}	
	
if (map['company_id']) {
	$('#payment-address input[name=\'company\'] + br').after('<span class="error">' + map['company'] + '</span>');
}	

if (map['tax_id']) {
	$('#payment-address input[name=\'tax_id\'] + br').after('<span class="error">' + map['tax_id'] + '</span>');
}	
														
if (map['addressLine1']) {
	$('#payment-address input[name=\'addressLine1\'] + br').after('<span class="error">' + map['addressLine1'] + '</span>');
}	

if (map['city']) {
	$('#payment-address input[name=\'city\'] + br').after('<span class="error">' + map['city'] + '</span>');
}	

if (map['postCode']) {
	$('#payment-address input[name=\'postCode\'] + br').after('<span class="error">' + map['postCode'] + '</span>');
}	

if (map['country']) {
	$('#payment-address select[name=\'country\'] + br').after('<span class="error">' + map['country'] + '</span>');
}
if (map['confirm']) {
 	$('#payment-address input[name=\'confirm\'] + br').after('<span class="error">' + map['confirm'] + '</span>');
}

if (map['password']) {
	$('#payment-address input[name=\'password\'] + br').after('<span class="error">' + map['password'] + '</span>');
}

//
if (map['zone']) {
	$('#payment-address select[name=\'zone_id\'] + br').after('<span class="error">' + map['zone'] + '</span>');
}

	
}

$(document).delegate('#button-guest','click', function() {
	$.ajax({
		url: '/pub-shopping-member/guest/init/',
		type: 'post',
		data: $('#payment-address input[type=\'text\'], #payment-address input[type=\'checkbox\']:checked, #payment-address select'),
		dataType: 'json',
		beforeSend: function() {
			$('#button-guest').attr('disabled', true);
			$('#button-guest').after('<span class="wait">&nbsp;<img src="/resources/images/loading.gif" alt="" /></span>');
		},	
		complete: function() {
			$('#button-guest').attr('disabled', false); 
			$('.wait').remove();
		},			
		success: function(json) {
			$('.warning, .error').remove();
			if (json && json.state && (json.state.indexOf("ERROR") != -1)) {
			
 				if (json['entity']) {
					memberFormError(json['entity']);
				}
 				if (json['message']) {
					alert(json['message']);
				} 
			} else {
				loadingShipping();
 			}	 
		},
		error: function(xhr, ajaxOptions, thrownError) {
			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
		}
	});	
});



$(document).delegate('#button-payment-address','click', function() {
	var type = $('input[name=\'paymentAddress\']:checked').attr('value');
	
  	$.ajax({
		url: '/pub-shopping-member/member/init/'+type+"/",
		type: 'post',
		data: $('#payment-address input[type=\'text\'], #payment-address input[type=\'password\'], #payment-address input[type=\'checkbox\']:checked, #payment-address input[type=\'radio\']:checked, #payment-address input[type=\'hidden\'], #payment-address select'),
		dataType: 'json',
		beforeSend: function() {
			$('#button-payment-address').attr('disabled', true);
			$('#button-payment-address').after('<span class="wait">&nbsp;<img src="/resources/images/loading.gif" alt="" /></span>');
		},	
		complete: function() {
			$('#button-payment-address').attr('disabled', false);
			$('.wait').remove();
		},			
		success: function(json) {
			$('.warning, .error').remove();
			
			if(json && json.state && (json.state.indexOf("ERROR") != -1)){
				var entity =  json['entity'];
 				if (entity) {
 					
 					for(var key in entity) {
						$('#payment-address [name='+key+']').after('<span class="error">' + entity[key] + '</span>');
 					}
 				}
 			}else{

				$.ajax({
					url: '/partial/step3/',
					dataType: 'html',
					success: function(html) {
						$('#shipping-address .checkout-content').css({opacity:0}).html(html).animate({opacity:1}, 1000);
					
						$('#payment-address .checkout-content').slideUp('slow');
						
						$('#shipping-address .checkout-content').slideDown('slow');
						
						$('#payment-address .checkout-heading a').css("visibility", "hidden")
						$('#shipping-address .checkout-heading a').css("visibility", "hidden")
						$('#shipping-method .checkout-heading a').css("visibility", "hidden")
						$('#payment-method .checkout-heading a').css("visibility", "hidden")
						
						$('#payment-address .checkout-heading a').css("visibility", "visible");	
						$("#shippingCountry").trigger("change");
					},
					error: function(xhr, ajaxOptions, thrownError) {
						alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
					}
				});
								
				$.ajax({
					url: '/partial/step2/',
					dataType: 'html',
					success: function(html) {
						$('#payment-address .checkout-content').css({opacity:0}).html(html).animate({opacity:1}, 1000);
 
						
					},
					error: function(xhr, ajaxOptions, thrownError) {
						alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
					}
				});		
 
			}}
 		,
		error: function(xhr, ajaxOptions, thrownError) {
			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
		}
	});	
});



$(document).delegate('#payment-address input[name=\'paymentAddress\']','change', function() {
	if (this.value == 'new') {
		$('#payment-existing').hide();
		$('#payment-new').show();
	} else {
		$('#payment-existing').show();
		$('#payment-new').hide();
	}
});


$(document).delegate('#shipping-address input[name=\'shippingAddress\']','change', function() {
	if (this.value == 'new') {
		$('#shipping-existing').hide();
		$('#shipping-new').show();
	} else {
		$('#shipping-existing').show();
		$('#shipping-new').hide();
	}
});


// Guest Shipping
$(document).delegate('#button-guest-shipping','click', function() {
	$.ajax({
		url: '/pub-shopping-member/guest-shipping-address/',
		type: 'post',
		data: $('#shipping-address input[type=\'text\'], #shipping-address select'),
		dataType: 'json',
		beforeSend: function() {
			$('#button-guest-shipping').attr('disabled', true);
			$('#button-guest-shipping').after('<span class="wait">&nbsp;<img src="/resources/images/loading.gif" alt="" /></span>');
		},	
		complete: function() {
			$('#button-guest-shipping').attr('disabled', false); 
			$('.wait').remove();
		},			
		success: function(json) {
			$('.warning, .error').remove();
			
			if (json['redirect']) {
				location = json['redirect'];
			} else if (json['error']) {
				if (json['error']['warning']) {
					$('#shipping-address .checkout-content').prepend('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/nico/image/close.png" alt="" class="close" /></div>');
					
					$('.warning').fadeIn('slow');
				}
								
				if (json['error']['firstname']) {
					$('#shipping-address input[name=\'firstname\']').after('<span class="error">' + json['error']['firstname'] + '</span>');
				}
				
				if (json['error']['lastname']) {
					$('#shipping-address input[name=\'lastname\']').after('<span class="error">' + json['error']['lastname'] + '</span>');
				}	
										
				if (json['error']['address_1']) {
					$('#shipping-address input[name=\'address_1\']').after('<span class="error">' + json['error']['address_1'] + '</span>');
				}	
				
				if (json['error']['city']) {
					$('#shipping-address input[name=\'city\']').after('<span class="error">' + json['error']['city'] + '</span>');
				}	
				
				if (json['error']['postcode']) {
					$('#shipping-address input[name=\'postcode\']').after('<span class="error">' + json['error']['postcode'] + '</span>');
				}	
				
				if (json['error']['country']) {
					$('#shipping-address select[name=\'country_id\']').after('<span class="error">' + json['error']['country'] + '</span>');
				}	
				
				if (json['error']['zone']) {
					$('#shipping-address select[name=\'zone_id\']').after('<span class="error">' + json['error']['zone'] + '</span>');
				}
			} else {
				$.ajax({
					url: '/partial/step4/',
					dataType: 'html',
					success: function(html) {
						$('#shipping-method .checkout-content').css({opacity:0}).html(html).animate({opacity:1}, 1000);
						
						$('#shipping-address .checkout-content').slideUp('slow');
						
						$('#shipping-method .checkout-content').slideDown('slow');
						
						$('#shipping-address .checkout-heading a').css("visibility", "hidden")
						$('#shipping-method .checkout-heading a').css("visibility", "hidden")
						$('#payment-method .checkout-heading a').css("visibility", "hidden")
							
						$('#shipping-address .checkout-heading').show();
					},
					error: function(xhr, ajaxOptions, thrownError) {
						alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
					}
				});				
			}	 
		},
		error: function(xhr, ajaxOptions, thrownError) {
			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
		}
	});	
});



$(document).delegate('#button-shipping-address','click', function() {
	
	var type = $('input[name=\'shippingAddress\']:checked').attr('value');
	
 
	
	$.ajax({
		url: '/pub-shopping-member/shipping-address/'+type+"/",
		type: 'post',
		data: $('#shipping-address input[type=\'text\'], #shipping-address input[type=\'password\'], #shipping-address input[type=\'checkbox\']:checked, #shipping-address input[type=\'radio\']:checked, #shipping-address select'),
		dataType: 'json',
		beforeSend: function() {
			$('#button-shipping-address').attr('disabled', true);
			$('#button-shipping-address').after('<span class="wait">&nbsp;<img src="/resources/images/loading.gif" alt="" /></span>');
		},	
		complete: function() {
			$('#button-shipping-address').attr('disabled', false);
			$('.wait').remove();
		},			
		success: function(json) {
			$('.warning, .error').remove();
			
			if(json && json.state && (json.state.indexOf("ERROR") != -1)){
				var entity =  json['entity'];
 				if (entity) {
 					
 					for(var key in entity) {
						$('#shipping-address [name='+key+']').after('<span class="error">' + entity[key] + '</span>');
 					}
 				}
 			}else {
				$.ajax({
					url: '/partial/step4/',
					dataType: 'html',
					success: function(html) {
						$('#shipping-method .checkout-content').css({opacity:0}).html(html).animate({opacity:1}, 1000);
						
						$('#shipping-address .checkout-content').slideUp('slow');
						
						$('#shipping-method .checkout-content').slideDown('slow');
						
						$('#shipping-address .checkout-heading a').css("visibility", "hidden")
						$('#shipping-method .checkout-heading a').css("visibility", "hidden")
						$('#payment-method .checkout-heading a').css("visibility", "hidden")
						
						$('#shipping-address .checkout-heading a').css("visibility", "visible");							
						
						$.ajax({
							url: '/partial/step3/',
							dataType: 'html',
							success: function(html) {
								$('#shipping-address .checkout-content').css({opacity:0}).html(html).animate({opacity:1}, 1000);
								$("#shippingCountry").trigger("change");
								
								
							},
							error: function(xhr, ajaxOptions, thrownError) {
								alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
							}
						});
						
						$.ajax({
							url: '/partial/step2/',
							dataType: 'html',
							success: function(html) {
								$('#payment-address .checkout-content').css({opacity:0}).html(html).animate({opacity:1}, 1000);
							},
							error: function(xhr, ajaxOptions, thrownError) {
								alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
							}
						});
						
					},
					error: function(xhr, ajaxOptions, thrownError) {
						alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
					}
				});	
			}  
		},
		error: function(xhr, ajaxOptions, thrownError) {
			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
		}
	});	
});





















$(document).delegate('#button-register','click', function() {
	$.ajax({
		url: '/pub-shopping-member/register/init/',
		type: 'post',
		data: $('#payment-address input[type=\'text\'], #payment-address input[type=\'password\'], #payment-address input[type=\'checkbox\']:checked, #payment-address input[type=\'radio\']:checked, #payment-address input[type=\'hidden\'], #payment-address select'),
		dataType: 'json',
		beforeSend: function() {
			$('#button-register').attr('disabled', true);
			$('#button-register').after('<span class="wait">&nbsp;<img src="/resources/images/loading.gif" alt="" /></span>');
		},	
		complete: function() {
			$('#button-register').attr('disabled', false); 
			$('.wait').remove();
		},			
		success: function(json) {
			$('.warning, .error').remove();
 			if (json && json.state && (json.state.indexOf("ERROR") != -1)) {
			
 				if (json['entity']) {
					memberFormError(json['entity']);
				}
 				if (json['message']) {
					alert(json['message']);
				}
 			}  else {
 				loadingShipping();
 			}
		},
		error: function(xhr, ajaxOptions, thrownError) {
			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
		}
	});	
});


$(document).delegate('#button-shipping-method','click', function() {
	$.ajax({
		url: '/pub-shopping-member/ship-method/',
		type: 'post',
		data: $('#shipping-method input[type=\'radio\']:checked, #shipping-method textarea'),
		dataType: 'json',
		beforeSend: function() {
			$('#button-shipping-method').attr('disabled', true);
			$('#button-shipping-method').after('<span class="wait">&nbsp;<img src="/resources/images/loading.gif" alt="" /></span>');
		},	
		complete: function() {
			$('#button-shipping-method').attr('disabled', false);
			$('.wait').remove();
		},			
		success: function(json) {
			$('.warning, .error').remove();
			
			if (json['redirect']) {
				location = json['redirect'];
			} else if (json['error']) {
				if (json['error']['warning']) {
					$('#shipping-method .checkout-content').prepend('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/nico/image/close.png" alt="" class="close" /></div>');
					
					$('.warning').fadeIn('slow');
				}			
			} else {
				$.ajax({
					url: '/partial/step5/',
					dataType: 'html',
					success: function(html) {
						$('#payment-method .checkout-content').css({opacity:0}).html(html).animate({opacity:1}, 1000);
						
						$('#shipping-method .checkout-content').slideUp('slow');
						
						$('#payment-method .checkout-content').slideDown('slow');

						$('#shipping-method .checkout-heading a').css("visibility", "hidden")
						$('#payment-method .checkout-heading a').css("visibility", "hidden")
						
						$('#shipping-method .checkout-heading a').css("visibility", "visible");	

					},
					error: function(xhr, ajaxOptions, thrownError) {
						alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
					}
				});					
			}
		},
		error: function(xhr, ajaxOptions, thrownError) {
			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
		}
	});	
});

$(document).delegate('#button-payment-method','click', function() {
	$.ajax({
		url: '/pub-shopping-member/payment-method/', 
		type: 'post',
		data: $('#payment-method input[type=\'radio\']:checked, #payment-method input[type=\'checkbox\']:checked, #payment-method textarea'),
		dataType: 'json',
		beforeSend: function() {
			$('#button-payment-method').attr('disabled', true);
			$('#button-payment-method').after('<span class="wait">&nbsp;<img src="/resources/images/loading.gif" alt="" /></span>');
		},	
		complete: function() {
			$('#button-payment-method').attr('disabled', false);
			$('.wait').remove();
		},			
		success: function(json) {
			$('.warning, .error').remove();
			
			if (json['redirect']) {
				location = json['redirect'];
			} else if (json['error']) {
				if (json['error']['warning']) {
					$('#payment-method .checkout-content').prepend('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/nico/image/close.png" alt="" class="close" /></div>');
					
					$('.warning').fadeIn('slow');
				}			
			} else {
				$.ajax({
					url: '/partial/step6/',
					dataType: 'html',
					success: function(html) {
						$('#confirm .checkout-content').css({opacity:0}).html(html).animate({opacity:1}, 1000);
						
						$('#payment-method .checkout-content').slideUp('slow');
						
						$('#confirm .checkout-content').slideDown('slow');
						
						$('#payment-method .checkout-heading a').css("visibility", "hidden")
						
						$('#payment-method .checkout-heading a').css("visibility", "visible");	
					},
					error: function(xhr, ajaxOptions, thrownError) {
						alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
					}
				});					
			}
		},
		error: function(xhr, ajaxOptions, thrownError) {
			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
		}
	});	
});

function quickConfirm(module){
	$.ajax({
		url: 'index.php?route=checkout/confirm',
		dataType: 'html',
		success: function(html) {
			$('#confirm .checkout-content').html(html);
			$('#confirm .checkout-content').slideDown('slow');
			
				
			$('.checkout-heading a').remove();
				
			$('#checkout .checkout-heading a').remove();
			$('#checkout .checkout-heading').append('<a>Modify &raquo;</a>');
			
			$('#shipping-address .checkout-heading a').remove();
			$('#shipping-address .checkout-heading').append('<a>Modify &raquo;</a>');	
			
			$('#shipping-method .checkout-heading a').remove();
			$('#shipping-method .checkout-heading').append('<a>Modify &raquo;</a>');	
			
			$('#payment-address .checkout-heading a').remove();			
			$('#payment-address .checkout-heading').append('<a>Modify &raquo;</a>');	
							
			$('#payment-method .checkout-heading a').remove();
			$('#payment-method .checkout-heading').append('<a>Modify &raquo;</a>');	

		},
		error: function(xhr, ajaxOptions, thrownError) {
			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
		}
	});	
}

$(document).delegate("#billingCountry",'change', function() {
	var countryId = $(this).val();	
	$.ajax({
		url : "/pub-shopping-member/country-zone/"+countryId+"/list/",
		type : "GET",
		dataType : "json",
		success : function(data){		
			if(data && data.state && (data.state.indexOf("ERROR") != -1)){
				johnny.error(data.message);
				return;
			}else{

				var zone = $('#billingZone');
				zone.empty();
			$(data).each(function(step,value){
				$('<option>').val(value.id).text(value.name).appendTo(zone);
				});
			var selectedId = $("#billingZone").attr("selectedid");
			if (selectedId){
				$("#billingZone").val(selectedId);
				$("#billingZone").removeAttr("selectedid");
			}
			}
		}
	});
	
	
	
});


$(document).delegate("#shippingCountry",'change', function() {
	var countryId = $(this).val();	
	$.ajax({
		url : "/pub-shopping-member/country-zone/"+countryId+"/list/",
		type : "GET",
		dataType : "json",
		success : function(data){		
			if(data && data.state && (data.state.indexOf("ERROR") != -1)){
				johnny.error(data.message);
				return;
			}else{

				var zone = $('#shippingZone');
				zone.empty();
			$(data).each(function(step,value){
				$('<option>').val(value.id).text(value.name).appendTo(zone);
				});
			var selectedId = $("#shippingZone").attr("selectedid");
			if (selectedId){
				$("#shippingZone").val(selectedId);
				$("#shippingZone").removeAttr("selectedid");
			}
 		}
		}
	});
});



